<!doctype html>
<html ng-app="diff_item">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="icon" href="../img/config.png">
    <!-- styles -->
    <link rel="stylesheet" type="text/css" href="../vendor/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="../vendor/angular/angular-toastr-1.4.1.min.css">
    <link rel="stylesheet" type="text/css" media='all' href="../vendor/angular/loading-bar.min.css">
    <link rel="stylesheet" type="text/css" href="../styles/common-style.css">
    <link rel="stylesheet" type="text/css" href="../vendor/select2/select2.min.css">
    <title>比较配置</title>
    <style>
        .comment-toggle {
            margin-left: 8px !important;
        }
        .diff-content {
            margin-top: 12px;
        }
    </style>
</head>

<body>

<apollonav></apollonav>

<div class="container-fluid apollo-container" ng-controller="DiffItemController">
    <section class="panel col-md-offset-1 col-md-10">
        <header class="panel-heading">
            <div class="row">
                <div class="col-md-7">
                    <h4 class="modal-title">比较配置
                        <small ng-show="syncItemStep == 1">(第一步:选择比较信息)</small>
                        <small ng-show="syncItemStep == 2">(第二步:查看差异配置)</small>
                    </h4>
                </div>
                <div class="col-md-5 text-right">
                    <button type="button" class="btn btn-primary" ng-show="syncItemStep > 1 && syncItemStep < 3"
                            ng-click="syncItemNextStep(-1)">上一步
                    </button>
                    <button type="button" class="btn btn-primary" ng-show="syncItemStep < 2"
                            ng-click="diff()">下一步
                    </button>
                    <button type="button" class="btn btn-info" data-dismiss="modal"
                            ng-click="backToAppHomePage()">返回到项目首页
                    </button>
                </div>
            </div>
        </header>
        <div class="panel-body">
            <div class="row" ng-show="syncItemStep == 1">
                <div class="alert-info alert no-radius">
                    <strong>Tips:</strong>
                    <ul>
                        <li>通过比较配置功能，可以查看多个环境、集群间的配置差异</li>
                    </ul>
                </div>
                <div class="form-horizontal">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">要比较的集群</label>
                        <div class="col-sm-6">
                            <apolloclusterselector apollo-app-id="pageContext.appId" apollo-default-all-checked="false"
                                                   apollo-select="collectSelectedClusters"
                                                   apollo-default-checked-env="pageContext.env"
                                                   apollo-default-checked-cluster="pageContext.clusterName"></apolloclusterselector>
                        </div>
                    </div>
                </div>
                <hr>
            </div>

            <!--step 2-->
            <div class="row" ng-show="syncItemStep == 2">
                <div class="row" style="margin-top: 10px;">
                    <div class="form-horizontal">
                        <div class="col-sm-12">
                            <label class="control-label">
                                <input type="checkbox"
                                       class="comment-toggle"
                                       ng-checked="showCommentDiff"
                                       ng-click="showCommentDiff=!showCommentDiff">
                                是否比较注释
                            </label>
                        </div>
                        <div class="col-sm-12 diff-content">
                            <table class="table table-bordered table-striped table-hover">
                                <thead>
                                <tr>
                                    <td>Key</td>
                                    <td ng-repeat="cluster in syncData.syncToNamespaces"
                                        ng-bind="cluster.env + ':' + cluster.clusterName + ':' + cluster.namespaceName + ':Value'"
                                    ></td>
                                    <td ng-show="showCommentDiff"
                                        ng-repeat="cluster in syncData.syncToNamespaces"
                                        ng-bind="cluster.env + ':' + cluster.clusterName + ':' + cluster.namespaceName + ':Comment'"
                                    ></td>
                                </tr>
                                </thead>
                                <tbody>
                                <tr ng-repeat="(key, itemsKeyedByCluster) in itemsKeyedByKey">
                                    <td width="15%" ng-bind="key"></td>
                                    <td ng-repeat="cluster in syncData.syncToNamespaces"
                                        ng-bind="(itemsKeyedByCluster[cluster.env + ':' + cluster.clusterName + ':' + cluster.namespaceName] || {}).value"></td>
                                    <td ng-show="showCommentDiff"
                                        ng-repeat="cluster in syncData.syncToNamespaces"
                                        ng-bind="(itemsKeyedByCluster[cluster.env + ':' + cluster.clusterName + ':' + cluster.namespaceName] || {}).comment"></td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <showtextmodal text="text"/>
</div>



<div ng-include="'../views/common/footer.html'"></div>

<!-- jquery.js -->
<script src="../vendor/jquery.min.js" type="text/javascript"></script>
<script src="../vendor/select2/select2.min.js" type="text/javascript"></script>

<!--angular-->
<script src="../vendor/angular/angular.min.js"></script>
<script src="../vendor/angular/angular-resource.min.js"></script>
<script src="../vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script>
<script src="../vendor/angular/loading-bar.min.js"></script>


<!-- bootstrap.js -->
<script src="../vendor/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>

<script src="../vendor/clipboard.min.js" type="text/javascript"></script>
<!--biz-->
<script type="application/javascript" src="../scripts/app.js"></script>
<script type="application/javascript" src="../scripts/services/AppService.js"></script>
<script type="application/javascript" src="../scripts/services/EnvService.js"></script>
<script type="application/javascript" src="../scripts/services/ConfigService.js"></script>
<script type="application/javascript" src="../scripts/services/UserService.js"></script>
<script type="application/javascript" src="../scripts/services/CommonService.js"></script>
<script type="application/javascript" src="../scripts/services/PermissionService.js"></script>

<script type="application/javascript" src="../scripts/AppUtils.js"></script>
<script type="application/javascript" src="../scripts/controller/config/DiffConfigController.js"></script>

<script type="application/javascript" src="../scripts/PageCommon.js"></script>
<script type="application/javascript" src="../scripts/directive/directive.js"></script>
<script type="application/javascript" src="../scripts/directive/show-text-modal-directive.js"></script>
</body>
</html>
